class ImagesController < ApplicationController
  filter_access_to :all

  def index
   if params[:artist_id]
     @item = Artist.find(params[:artist_id])
   elsif params[:edition_id]
     @item = Edition.find(params[:edition_id])
   elsif params[:genre_id]
     @item = Genre.find(params[:genre_id])
   elsif params[:label_id]
     @item = Label.find(params[:label_id])
   elsif params[:song_id]
     @item = Song.find(params[:song_id])
   end

   @images = @item.images
  end

  def delete
    image = Image.find(params[:id])

    if image.delete
      flash[:notice] = 'Image successfully removed.'
    else
      flash[:errors] = 'Unable to remove image, please try again.'
    end
  end

end
